// pages/gangManage/productAfterSale/productAfterSale.js 

const app = getApp()
var util = require('../../../utils/util.js')
var http = require('../../../utils/server.js')

Page({
  data: {
    afterSale: "",
  },


  onLoad: function(option) {
    var that = this
    that.setData({
      product_id: option.product_id
    })

    http.post({
      url: "product/getAfterSaleIntro",
      product_id: that.data.product_id
    }, function(data) {
      console.log('售后说明', data)
      that.setData({
        afterSale: data.content
      })
    })
  },
  formSubmit: function(e) {
    var that = this
    console.log(e.detail.value)
    http.post({
      url: "product/editProductAfterSale",
      product_id: that.data.product_id,
      content: e.detail.value.afterSale
    }, function(data) {
      util.showSuccess('修改成功', function() {
        var pages = getCurrentPages();
        if (pages.length > 1) {
          var prePage = pages[pages.length - 2];
          prePage.setAfterSale("已设置")
        }
        wx.navigateBack({
          delta: 1
        })
      })
    })
  }
})